export default defineEventHandler(async (event) => {
  const id = getRouterParam(event, 'id')
  
  // 模拟订单数据
  const orders: Record<string, any> = {
    '1': {
      id: '1',
      orderNo: 'ORD20250110001',
      userId: 'user1',
      items: [
        {
          id: 'item1',
          productId: '1',
          productTitle: 'Vue3 + Vite 后台管理系统',
          productCover: 'https://picsum.photos/seed/admin-system/600/400',
          price: 299,
          quantity: 1,
        },
      ],
      totalAmount: 299,
      status: 'paid',
      paymentMethod: 'alipay',
      createdAt: '2025-01-10 10:30:00',
      paidAt: '2025-01-10 10:35:00',
    },
    '2': {
      id: '2',
      orderNo: 'ORD20250109002',
      userId: 'user1',
      items: [
        {
          id: 'item2',
          productId: '2',
          productTitle: 'React18 电商系统全栈项目',
          productCover: 'https://picsum.photos/seed/ecommerce/600/400',
          price: 499,
          quantity: 1,
        },
        {
          id: 'item3',
          productId: '3',
          productTitle: 'Nuxt3 内容管理系统',
          productCover: 'https://picsum.photos/seed/cms/600/400',
          price: 399,
          quantity: 1,
        },
      ],
      totalAmount: 898,
      status: 'pending',
      paymentMethod: 'wechat',
      createdAt: '2025-01-09 15:20:00',
    },
  }
  
  const order = orders[id as string]
  
  if (!order) {
    throw createError({
      statusCode: 404,
      message: '订单不存在',
    })
  }
  
  return {
    code: 200,
    message: 'success',
    data: order,
  }
})

